<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.xq.shop.util.*"%>
<%@page import="com.xq.shop.po.Menu"%>
<%@page import="com.xq.shop.vo.Operator"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!Doctype Html Public "-//W3C//Dtd Html 4.0 Transitional//En">
<html>
  <head>
    <base href="<%=basePath%>">
    <meta http-equiv="Cache-Control" content="no-cache" />
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<jsp:include page="/jsp/admin/common.jsp" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>resource/admin_css/index.css"/>
	<%
		Operator operator = (Operator)request.getSession().getAttribute(Const.Operator_Session);
		List<Menu> menu_1st = operator.getMenu_1st();
		List<Menu> menu_2nd = operator.getMenu_2nd();
		
		Collections.sort(menu_1st, new SortMenuBySeq());
		Collections.sort(menu_2nd, new SortMenuBySeq());
	%>
  </head>
  <body>
  <table class="main">
		<tr>
			<td class="logo blue_bg">
				<a href="#">
					<img src="<%=basePath %>resource/admin_images/header_logo.gif" alt="logo" />
				</a>
			</td>
			<td class="blue_bg">
				<div id="nav" class="nav">
					<ul>
						<%
							for(Menu menu : menu_1st){
						%>
							<li>
								<a href="<%=menu.getAction_url() %>" ><%=menu.getName() %></a>
							</li>
						<%
							}
						%>
					</ul>
				</div>
				<div class="link">
					<a href="" target="_blank">官方网站</a>|
					<a href="" target="_blank">关于我们</a>
				</div>
				<div class="link">
					<strong>管理员</strong>
					你好！
					<a href="" target="iframe">[账号设置]</a>
					<a href="<%=basePath %>admin/user_logout.do" target="_top" >[注销]</a>
				</div>
			</td>
		</tr>
		<tr>
			<td id="menu" class="menu">
			<%
				for(Menu menu : menu_1st){
			%>
				<dl id="dl_menu_2nd_<%=menu.getId() %>" style="display: none;">
					<%
						for(Menu menu2 : menu_2nd){
							
							if(menu.getId() != menu2.getParent_id()) continue;
							
					%>
							<dd><a href="<%=menu2.getAction_url() %>"><%=menu2.getName() %></a></dd>
					<%
						}
					%>
				</dl>
			<%
				}
			%>
			</td>
			<td>
				<iframe id="iframe" name="iframe" frameborder="0" scrolling="auto" ></iframe>
			</td>
		</tr>
	</table>
</body>
<script type="text/javascript">
$().ready(function() {
	window.pageVar = {};
	<%
	if(menu_1st.size() > 0){
	%>
	pageVar.itemSelected = '<%=menu_1st.get(0).getId() %>';	//全局变量
	select_menu(pageVar.itemSelected, '1st');
	<% 
	} 
	%>
	$("#iframe").height($("#menu").height());
});

/*
 * 选择菜单
 * */
function select_menu(_id, _type, _url){
	
	/*一级菜单事件是展开二级菜单显示*/
	if(_type == "1st"){
		$("#dl_menu_2nd_" + pageVar.itemSelected).hide();
		$("#dl_menu_2nd_" + _id).show();
		pageVar.itemSelected = _id;	//设置已选项id
	} else if(_type == "2nd"){	/*二级菜单点击事件是在iframe中展示内容*/
		$("#iframe").attr("src", _id + "?new=" + Math.random());
	}
}
</script>
</html>